/*
 * Hyuga: A Density-Grid Stream Clustering Platform.
 * Copyright (C) 2014 PUC-Rio/Laboratory for Advanced Collaboration
 *
 * Hyuga is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Hyuga is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Hyuga.  If not, see <http://www.gnu.org/licenses/>.
 */
package br.pucrio.inf.lac.konoha.hyuga.others.csv;

import java.io.IOException;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class CSVSimpleRandIndex {

	/**
	 * Main Routine.
	 * 
	 * @param args a CSV filename.
	 * @throws IOException If log files cannot be created.
	 * @throws IllegalAccessException if args is null. 
	 */
	public static void main(String[] args) throws IOException {
	    Scanner scan = new Scanner(System.in);
	    
	    System.out.println("Output Set");
	    Set<String> outputSet = new HashSet<String>();
	    for (String element : scan.nextLine().split(",")) {
	        outputSet.add(element);
	    }
	    
	    System.out.println("DBSCAN Set");
	    Set<String> dbscanSet = new HashSet<String>();
        for (String element : scan.nextLine().split(",")) {
            dbscanSet.add(element);
        }
        
        Set<String> truePositive = new HashSet<String>(outputSet);
        truePositive.retainAll(dbscanSet);
        
        Set<String> falsePositive = new HashSet<String>(outputSet);
        falsePositive.removeAll(dbscanSet);

        Set<String> falseNegative = new HashSet<String>(dbscanSet);
        falseNegative.removeAll(outputSet);
        
        double TP = truePositive.size();
        double FP = falsePositive.size();
        double FN = falseNegative.size();
        
        double randIndex = TP / (TP + FP + FN);
        System.out.println("Rand Index: " + randIndex);
        
        scan.close();
	    System.exit(0);
	}
}
